/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.maze.behaviours;

import java.util.Random;
import org.maze.individual.Individual;

/**
 *
 * @author Thomas
 */
public class InvertionMutateBehaviour implements IMutateBehaviour{
    private static final Random rand = new Random();

    public byte[] mutate(byte[] genome) {
        for(int i = 0; i<genome.length; i++){
            if(rand.nextInt(1000)==6){
                if(genome[i]==Individual.EAST){
                    genome[i]=Individual.WEST;
                }else if(genome[i]==Individual.WEST){
                    genome[i]=Individual.EAST;
                }else if(genome[i]==Individual.NORTH){
                    genome[i]=Individual.SOUTH;
                }else if(genome[i]==Individual.SOUTH){
                    genome[i]=Individual.NORTH;
                }
            }
        }
        return genome;
    }

}
